package edu.calvin.djs32.cs214.interpreters.frontend;

import org.antlr.runtime.ANTLRStringStream;
import org.antlr.runtime.CharStream;
import org.antlr.runtime.CommonTokenStream;
import org.antlr.runtime.Lexer;
import org.antlr.runtime.Parser;
import org.antlr.runtime.RecognitionException;
import org.antlr.runtime.TokenStream;
import org.antlr.runtime.tree.Tree;
import org.antlr.runtime.tree.TreeParser;
import org.norecess.antlr.IANTLRFrontEnd;

public class Hobbes2008FrontEnd implements IANTLRFrontEnd {

	public Lexer createLexer(String arg0) {
		return new Hobbes2008Lexer(new ANTLRStringStream(arg0));
	}

	public Parser createParser(TokenStream arg0) {
		return new Hobbes2008Parser(arg0);
	}

	public TreeParser createTreeParser(Tree arg0) {
		throw new IllegalStateException("unimplemented!");
	}

	public Tree process(CharStream stream) throws RecognitionException {
	    Hobbes2008Parser parser = new Hobbes2008Parser(new CommonTokenStream(
	        new Hobbes2008Lexer(stream)));
	    Tree tree = (Tree) parser.program().getTree();
	    return tree;
	}

}
